import  * as contains  from './contains';
import { fromJS } from 'immutable';

const defaultState = fromJS({
	ScrollShow: false,
	topicList: [],
	articleList: [],
	articlePage: 1,
	recommendList: [],
	writerList: []

});

const changeHomeDate = (state, action) => {
	return state.merge({
				topicList: fromJS(action.topicList),
				articleList: fromJS(action.articleList),
				recommendList: fromJS(action.recommendList),
				writerList: fromJS(action.writerList)
			})
}

export default (state = defaultState, action) => {
	switch(action.type) {
		case contains.CHANGE_HOME_DATA:
			return changeHomeDate(state, action)
		case contains.GET_MORE_LIST:
			return state.merge({
			'articleList': state.get('articleList').concat(action.list),
			'articlePage': action.nextPage
			})
		case contains.EWM_SHOW:
			return state.set('show', true)
		case contains.GET_SCROLL:
			return state.set('ScrollShow', action.show);
		default:
			return state;
	}
}
